import time
from PyQt5.QtWidgets import *
from PyQt5 import QtCore

app = QApplication([])
app.setStyle("Fusion")
window = QWidget()
mainLayout = QFormLayout()

# title group
titleLayout = QHBoxLayout()
titleLayout.addStretch()
# QLabel
titleLayout.addWidget(QLabel("Style"))
# QComboBox
comnobox = QComboBox()
comnobox.addItem("Fusion")
comnobox.addItem("Windows")
comnobox.addItem("WindowsVista")
titleLayout.addWidget(comnobox)
# QCheckBox
useCheckbox = QCheckBox("Use style1's standard palette")
titleLayout.addWidget(useCheckbox)
disCheckbox = QCheckBox("Disable widgets")
titleLayout.addWidget(disCheckbox)

# Groups
# groups_Box = QGroupBox()
# groups_Layout = QGridLayout()

# Group 1
g1_GroupBox = QGroupBox("Group 1")
g1_layout = QFormLayout()
g1_layout.addRow(QLabel("Radio button 1"), QRadioButton())
g1_layout.addRow(QLabel("Radio button 2"), QRadioButton())
g1_layout.addRow(QLabel("Radio button 3"), QRadioButton())
g1_checkbox = QCheckBox("Tri-state check box")
g1_checkbox.setTristate(True)
g1_layout.addRow(g1_checkbox)
g1_GroupBox.setLayout(g1_layout)

# Group 2
g2_GroupBox = QGroupBox("Group 2")
g2_layout = QFormLayout()
g2_pushButton_1 = QPushButton("Default Push Button")
g2_pushButton_1.setDefault(True)
g2_layout.addRow(g2_pushButton_1)

g2_pushButton_2 = QPushButton("Toggle Push Button")
g2_layout.addRow(g2_pushButton_2)

g2_pushButton_3 = QPushButton("Flat Push Button")
g2_pushButton_3.setFlat(True)
g2_layout.addRow(g2_pushButton_3)

g2_GroupBox.setLayout(g2_layout)

# Group 3
g3_GroupBox = QGroupBox("Group 3")
g3_layout = QFormLayout()
g3_tabsWidget = QTabWidget()
g3_tabsWidget.addTab(QTableWidget(10, 20), "Table")
g3_tabsWidget.addTab(QLineEdit(), "Text Edit")
g3_layout.addRow(g3_tabsWidget)
g3_GroupBox.setLayout(g3_layout)

# Group 4
g4_GroupBox = QGroupBox("Group 4")
g4_layout = QFormLayout()
g4_lineEdit = QLineEdit()
g4_lineEdit.setEchoMode(QLineEdit.Password)
g4_layout.addRow(g4_lineEdit)

g4_spinBox = QSpinBox()
g4_layout.addRow(g4_spinBox)

g4_dateTimeEdit = QDateTimeEdit()
g4_dateTimeEdit.setDisplayFormat("yyyy/MM/dd HH:mm:ss")
g4_dateTimeEdit.setCalendarPopup(True)
present_qdatetime = QtCore.QDateTime()
present_qdatetime.setSecsSinceEpoch(time.time())
g4_dateTimeEdit.setDateTime(present_qdatetime)
g4_layout.addRow(g4_dateTimeEdit)

slider = QSlider(QtCore.Qt.Horizontal)
slider.setTickPosition(QSlider.TicksBothSides)
slider.setTickInterval(10)
slider.setSingleStep(1)
g4_layout.addRow(slider)
g4_GroupBox.setLayout(g4_layout)

# 拉伸系数
# groups_Layout.setColumnStretch(1, 1)

g12_Layout = QHBoxLayout()
g12_Layout.addWidget(g1_GroupBox)
g12_Layout.addWidget(g2_GroupBox)

g34_Layout = QHBoxLayout()
g34_Layout.addWidget(g3_GroupBox)
g34_Layout.addWidget(g4_GroupBox)

mainLayout.addRow(titleLayout)
mainLayout.addRow(g12_Layout)
mainLayout.addRow(g34_Layout)

window.setLayout(mainLayout)
window.show()
app.exec_()
